package com.atguigu.bigdata.chapter05.transform;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author lzc
 * @Date 2022/9/2 10:26
 */
public class Flink03_Filter {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        
        
        // 需要查询数据库才能确定如何对value做什么样的操作
        env
            .fromElements(1, 10, 3, 6, 9)
            .filter(new FilterFunction<Integer>() {
                @Override
                public boolean filter(Integer value) throws Exception {
                    //return value % 2 == 0;
                    if (value % 2 == 0) {
                        return true;
                    }else {
                        return false;
                    }
                }
            })
            .print();
        
        
        
        
        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
/*


 */